(function(){
	
	if (!window.CJ) {
		window.CJ = {};
	}

	function Search () {
		this.name = 'Search';
		this.bindEvent();
	}
	
	Search.prototype = new EventCtl();
	Search.prototype.bindEvent = function () {
		$('#global .search').on('click', function() {
			CJ.Scene.searchDetail();
		});
		$('#global .search').on('mouseenter', function() {
			if(!CJ.isRightDetailEntry) {
			$('#global li').removeClass('focus');
			$('#global .search').addClass('focus');
			CJ.Scene.setDelegate(CJ.Scene["Search"]);
			}
		});
	};
	Search.prototype.down = function () {
		CJ.Scene.banner();
	};
	Search.prototype.left = function () {
		CJ.Scene.myinfo();
	};
	Search.prototype.right = function () {
		CJ.Scene.promotion();
	};
	Search.prototype.back = function () {
		$("#wrap").removeClass('search');
		$('#global li').removeClass('focus');
		CJ.Scene.channel();
	};
	Search.prototype.enter = function () {
		CJ.Scene.searchDetail();
	};
	
	function SearchDetail () {
		this.name = 'SearchDetail';
		this.bindEvent();
	}
	
	SearchDetail.prototype = new EventCtl();
	SearchDetail.prototype.bindEvent = function () {
	};
	SearchDetail.prototype.left = function () {
	};
	SearchDetail.prototype.right = function () {
	};
	SearchDetail.prototype.back = function () {
		CJ.Scene.search();
	};
	SearchDetail.prototype.enter = function () {
	};
	$.extend(CJ.Scene, {
							search: function(){
								CJ.isRightDetailEntry = false;
								$("#wrap").removeClass().addClass('ch');
								$('#global li').removeClass('focus');
								$('#global .search').addClass('focus');
								this.setDelegate(this["Search"]);
							},
							searchDetail : function () {
								CJ.isRightDetailEntry = true;
								$("#wrap").removeClass().addClass('ch search');
								$('#global li').removeClass('focus');
								$('#search input').focus();
								this.setDelegate(this["SearchDetail"]);
							}
						});

	$(document).ready(function(){
		CJ.Scene["Search"] = new Search();
		CJ.Scene["SearchDetail"] = new SearchDetail();
	});

})();